﻿#ifndef BIZ_H
#define BIZ_H

#include "bizeditor.h"
#include "epi_bizadd.h"
#include "detailadd.h"

#define ETC_BIZ "/epiboly.ini"

namespace Ui {
class Biz;
}

class Biz : public BizEditor
{
    Q_OBJECT

public:
    explicit Biz(QWidget *parent = 0);
    ~Biz();

    void updateView();

    void generateMenu();
    void createMenu();

    bool loadColumnWidth();
    void saveColumnWidth();
    void setHeaderData();

    void save();
    void revert();

    void newItem();
    void en_finish();
    void en_finish_direct();
    void en_remove();
    void en_loss();
    void en_stock();
    void edit_on();
    void edit_off();

    void updateDetail(const QString &uid);
    void updateStuff(const QString &uid);
    QString getContractorInfo(const QString &uid);

private slots:
    void on_indexView_clicked(const QModelIndex &index);
    void on_indexView_doubleClicked(const QModelIndex &index);

    void on_indexView_pressed(const QModelIndex &);
    void on_detailView_pressed(const QModelIndex &);
    void on_stuffView_pressed(const QModelIndex &);

private:
    Ui::Biz *ui;

    QString detailTable;
    QString stuffTable;

    bool loadDetailColWidthFlag;
    QMap<int,int> detailColWidth;

    bool loadStuffColWidthFlag;
    QMap<int,int> stuffColWidth;

    QSqlTableModel *detailModel;
    QSqlTableModel *stuffModel;
};

#endif // BIZ_H
